<?php
/**
 * Created by PhpStorm.
 * User: 狗剩先生
 * Date: 2018/12/27
 * Time: 1:22
 */

namespace app\admin\controller;

use think\Controller;

class Member extends Controller
{

    public function index()
    {
        $data = input('get.');
        $sdata = [];
        $start_time = '';
        $end_time = '';
        $result = '';
        if (!empty($data['start_time']) &&  !empty($data['end_time'])  && strtotime($data['end_time']) > strtotime($data['start_time'])) {
            $start_time = strtotime($data['start_time']);
            $end_time = strtotime($data['end_time']);
        }
        if (!empty($data['username'])){
            $result = $sdata['username'] = $data['username'] ;
        }

        if (!empty($result)){
            $res = model('member')
                ->where('username', 'like', '%' . $result . "%")
                ->where('create_time', 'between', [$start_time, $end_time])->select();
        }   else {
            $res = model('member')->where('id', '>', 0)->select();
        }
        
        return $this->fetch('', [
            'dataLength' => sizeof($res),
            'userInfo' => $res
        ]);
    }
}